package cn.itcast.demo.controller;


import cn.itcast.demo.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.Date;

@Controller
public class HelloController {

    @GetMapping("hello")
    public String sayHello(Model model) {
        //SpringMVC中把值存入model中会自动想request域中共享内容
        model.addAttribute("info", "hello thymelraf");
        return "heima63";
    }

    @GetMapping("show2")
    public String show2(Model model) {
        User user = new User();
        user.setAge(21);
        user.setName("Jack Chen");
        user.setFriend(new User("李小龙", 30));

        model.addAttribute("user", user);
        return "show2";
    }

    @GetMapping("show3")
    public String show3(Model model) {


        model.addAttribute("today", new Date());
        return "show3";
    }

    @GetMapping("show4")
    public String show4(Model model) {


        model.addAttribute("today", "1+1");
        return "show4";
    }

    @GetMapping("show5")
    public String show5(Model model) {
        model.addAttribute("star", "刘德华");
        return "show5";
    }

    @GetMapping("show6")
    public String show6(Model model) {
        User user = new User();
        user.setAge(21);
        user.setName("Jack Chen");
        user.setFriend(new User("李小龙", 30));


        model.addAttribute("users", Arrays.asList(user, user, user, user));
        return "show6";
    }

    @GetMapping("show7")
    public String show7(Model model) {
        User user = new User();
        user.setAge(21);
        user.setName("Jack Chen");
        user.setFriend(new User("李小龙", 30));
        model.addAttribute("user", user);
        String info = "禁提阿尼澳元啊";
        model.addAttribute("info", info);
        Long id = 123213213L;
        model.addAttribute("id", id);


        return "show7";
    }


}
